<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>最小公倍数</title>
</head>
<body>
    <script>
        var num1 = 14;
        var num2 = 18;

        //比较最大值
        var maxNum;
        num1>num2?maxNum=num1:maxNum=num2;

        //定义最小公倍数
        var minCom;
        //i最大值为num1*num2
        for(var i = maxNum;i <= num1*num2;i++){
            //判断是否能同时整除两个数
            if(i%num1 === 0 && i%num2 === 0){
                minCom = i;
                //因为取最小，所以后面有符合的不合适，要中断
                break;
            }
        }
        console.log(num1+'和'+num2+'的最小公倍数为:',minCom);
        console.log('上限值为:',num1*num2)

    </script>
</body>
</html>